<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="./js/vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 
      v-model 它是一个【语法糖】，它是 value和input/change事件集合体，它实现了双向绑定
    -->
    <!-- 绑定文本框 :value="username" @input="e=>username=e.target.value" -->
    <div>
      <input type="text" v-model="username">
    </div>
    <!-- 绑定多行文本框 -->
    <div>
      <textarea v-model="intro"></textarea>
    </div>
    <div>
      <!-- 绑定单个复选框 值为boolean -->
      <input type="checkbox" v-model="remember">
    </div>
    <div>
      <!-- 多个复选框 值为数组  value值要是在lessons数组中，则勾选 -->
      <input type="checkbox" value="html" v-model="lessons">html
      <input type="checkbox" value="css" v-model="lessons">css
      <input type="checkbox" value="js" v-model="lessons">js
    </div>
    <div>
      <!-- sex值是value值要是一样的话，则选中 -->
      <input type="radio" value="男" v-model="sex">男
      <input type="radio" value="女" v-model="sex">女
    </div>
    <div>
      <!-- 下拉 -->
      <select v-model="selected">
        <option>请选择</option>
        <option>HTML</option>
        <option>CSS</option>
        <option>JS</option>
      </select>
    </div>


    <hr>
    <button @click="onFormData">获取表单数据</button>

  </div>

  <script>

    new Vue({
      el: '#app',
      data: {
        username: '',
        intro: '',
        remember: true,
        lessons: [],
        sex: '男',
        selected: ''
      },
      methods: {
        onFormData() {
          console.log(this.$data)
        }
      }
    })
  </script>
</body>

</html>